package com.eascs.banknet.data.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.eascs.banknet.common.dao.BaseCrmDao;
import com.eascs.banknet.data.entity.CrmDditemEntity;

@Repository
public class DditemDao extends BaseCrmDao {
	public Map<String, Object> getDdItemByCode(String ddCode) {
		String sql = "select t2.* from pub_datadictionary t1, pub_dditem t2 where t1.dd_no = t2.dd_no and  t1.dd_code = ?";
		List<CrmDditemEntity> list = super.findEntitys(sql, CrmDditemEntity.class, ddCode);
		Map<String, Object> map = new HashMap<>();
		for (CrmDditemEntity entity : list) {
			map.put(entity.getItemCode(), entity.getItemName());
		}
		return map;
	}

	public String getItemNameByNo(String ddCode, String itemCode) {
		String sql = "select item_name from pub_datadictionary t1, pub_dditem t2 " + "where t1.dd_no = t2.dd_no and t1.dd_code = ? and t2.item_code = ?";
		return super.findString(sql, ddCode, itemCode);
	}
}
